<?php

	if ( !isset($_REQUEST["files"]) ) die();
	
	$filesStr = $_REQUEST["files"];
	$files = explode(",", $filesStr);
	
	$totalWidth = 0;
	$totalHeight = 0;
	$imageWidth = 0;
	$imageHeight = 0;
	
	foreach( $files as $file ) {
		$info = getimagesize($file);
		if ( $imageWidth == 0 ) $imageWidth = $info[0];
		if ( $imageHeight == 0 ) $imageHeight = $info[1];
		if ( $totalHeight == 0 ) $totalHeight = $info[1];
		$totalWidth += $info[0];
	}
	
	$canvas = imagecreatetruecolor($totalWidth, $totalHeight);
	imagealphablending( $canvas, false );
	
	$i = 0;
	foreach( $files as $file ) {
		$image = imagecreatefrompng($file);
		imagecopy( $canvas, $image, ($i * $imageWidth), 0, 0, 0, $imageWidth, $imageHeight );
		$i++;
	}
	
	header( "Content-Type: image/png" );
	imagesavealpha( $canvas, true );
	imagepng( $canvas );
	
	imagedestroy($canvas);
	imagedestroy($image);

?>